﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using EraNet.Core;
using EraNet.Data;
using EraNet.Core.Model.Test;
using EraNet.Core.Model.SysManage;

using EraNet.Common;
using EraNet.Services.Account;
using EraNet.Services.Test;
using EraNet.Core.Model.Account;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using EraNet.Services.SysManage;

namespace EraNet.SysAdmin.Controllers
{
    public class AccountController : Controller
    {
        #region Fields
        private readonly IAdminMemberService _iadminmemberServices;
        private readonly ISysCardsService _syscardsService;
        #endregion

        #region Constructors
        public AccountController(IAdminMemberService _IAdminMemberService, ISysCardsService syscardsService)
        {
            this._iadminmemberServices = _IAdminMemberService;
            this._syscardsService = syscardsService;
        }
        #endregion

        // GET: /Account/

        public ActionResult Index()
        {
            string cdno = "ZY";
            int j = 10460009;
            for (int i = 1046009; i <= 1048009; i++)
            {
                string pwd = Common.StrTools.RandomString(12, 0);
                string salt = Common.StrTools.RandomString(4, 0);
                SysCards model = new SysCards();
                model.AllotId = 0;
                model.CardNo = i;
                model.CardPassword = pwd;
                model.CardType = 1;
                model.CreateDate = DateTime.Now;
                model.IsValid = true;
                model.Markstr = cdno;
                model.Salt = salt;
                model.SchoolId = 0;
                _syscardsService.InsertCard(model);
            }
            return View();
        }

        public ActionResult MemberList()
        {
            return View();
        }

        public JsonResult AjaxMemberList(int? page)
        {
            int pageIndex = page ?? 1;
            int pagecount = 0;
            var list = _iadminmemberServices.SelectPager(pageIndex, 10,1,0,out pagecount);
            return Json(new { total = pagecount, list = list }, JsonRequestBehavior.AllowGet);
        }

        public ActionResult Memberinfo(int? id)
        {
            return View();
        }
    }
}
